import json
import logging
from typing import Optional

import tornado.httpclient
from tornado.httputil import HTTPHeaders

from configs import errorCode
from views import BaseHandler

import aiomysql


class DemoHandler(BaseHandler):

    async def post(self, name):
        # print(name)
        # # print(self.request.body)
        #
        # # print(self.request.arguments)
        #
        # # 查询参数
        # # print(self.get_argument("ab", "no"))
        # # print(self.get_query_argument("cd", "no"))
        # # print(self.path_kwargs)
        #
        # # 表单参数获取
        # # print(self.get_body_argument("aaa", "ddd"))
        # # self.write_json(errorCode.OK, None)
        #
        # print("ss", self.current_user)
        # print(self.write_json(data=self.current_user))
        # print(self.get_body_argument('li'))
        # res = eval(self.get_body_argument('li'))
        conn: aiomysql.Connection
        cursor: aiomysql.Cursor

        async with self.pool.acquire() as conn:
            async with conn.cursor(aiomysql.DictCursor) as cursor:
                print(conn.get_autocommit())
